package structurebasicdemo;

public class Main5 {
    private final java.util.LinkedList list = new java.util.LinkedList();

    public static void main(String[] args) {
        Main5 stack = new Main5();
        for (int i = 30; i < 40; i++)
            stack.push(new Integer(i));
        System.out.println(stack.top());
        System.out.println(stack.pop());
        System.out.println(stack.pop());
        System.out.println(stack.pop());
    }

    public void push(Object v) {
        list.addFirst(v);
    }

    public Object top() {
        return list.getFirst();
    }

    public Object pop() {
        return list.removeFirst();
    }
}
